package com.ruoyi.project.ypjxc.service.impl;

import com.ruoyi.project.ypjxc.domain.YFactory;
import com.ruoyi.project.ypjxc.mapper.YpjxcFactoryMapper;
import com.ruoyi.project.ypjxc.service.YpjxcFactoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class YpjxcFactoryServiceImpl implements YpjxcFactoryService {
    @Autowired
    private YpjxcFactoryMapper factoryMapper;

    /**
     * 查询工厂信息
     * @param factory 工厂信息
     * @return
     */
    @Override
    public List<YFactory> selectYFactoryList(YFactory factory) {
        return factoryMapper.selectYFactoryList(factory);
    }

    /**
     * 添加工厂信息
     * @param factory 工厂信息
     * @return
     */
    @Override
    public int insertYFactory(YFactory factory) {
        return factoryMapper.insertYFactory(factory);
    }

    /**
     *
     * 修改工厂信息
     * @param factory 工厂信息
     * @return
     */
    @Override
    public int updateYFactory(YFactory factory) {
        return factoryMapper.updateYFactory(factory);
    }

    /**
     * 根据工厂id查询
     * @param factoryId 工厂ID
     * @return
     */
    @Override
    public YFactory selectYFactoryById(Long factoryId) {
        return factoryMapper.selectYFactoryById(factoryId);
    }

    /**
     * 批量删除工厂信息
     * @param factoryId 需要删除的工厂ID
     * @return
     */
    @Override
    @Transactional
    public int deleteYFactoryByIds(Long[] factoryId) {
        int i = factoryMapper.deleteYFactoryByIds(factoryId);
        factoryMapper.deleteYFactoryDrugByIds(factoryId);
        factoryMapper.deleteYFactorySupplierByIds(factoryId);
        return i;
    }


}
